package cn.tedu.io.serial;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;

public class ObjectInputStreamDemo {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        //创建流对象
        ObjectInputStream ois=new ObjectInputStream
                (new FileInputStream("p.data"));


        //反序列化---读取字节信息转成对应对象
        Person p=(Person) ois.readObject();


        //展示数据
        System.out.println(p.getName()+","+p.getAge());


        //关流
        ois.close();
    }
}
